function[featureVector] = calculateFeatures(image)
% Extracts features of a given image.
%
%   INPUT
%   image...........an image in binary format
%   OUTPUT
%   featureVector...a vector, containing the following features: aspect
%                   ratio, formfactor, compactness

    image = bwlabel(image);
    features = regionprops(image,{'Area' 'Perimeter' 'MajorAxisLength' 'MinorAxisLength'});
        
    area=features(:).Area;
    perimeter=features(:).Perimeter;
    majoraxis=features(:).MajorAxisLength;
    minoraxis=features(:).MinorAxisLength;
    
    aspectratio=minoraxis/majoraxis;
    formfactor=(4*pi*area)/(perimeter^2);
    compactness=sqrt((4*area)/(pi*(majoraxis^2)));
    
    featureVector = [aspectratio formfactor compactness];
end
